Log Analysis and Visulization

In [1]:
import utils
import os
from os import path
import datetime
import pandas as pd

Result

  • Statistics Summary
    • transaction per second
    • time per block
    • size
    • gas
  • Features vs Time / Block Height (with all shards / per shard)
    • staking transaction per second
    • total transaction per second
    • transaction per second
    • time per block
    • size
    • gas
In [2]:
if __name__ == "__main__":
    
    date = datetime.date.today()-datetime.timedelta(days=1)
    name = "ostn_"+date.strftime("%Y_%m_%d")+".log"
    fig_dir = "../../graphs/test_logs/ostn/" + date.strftime("%Y_%m_%d") + "/"
    log_dir = "/home/ubuntu/jupyter/monitor/mini_explorer/data/" + name
    html_dir = "../../docs/graphs/test_logs/ostn/" + date.strftime("%Y_%m_%d") + "/"

    data = [html_dir, fig_dir]
    for directory in data:
        if not path.exists(directory):
            try:
                os.makedirs(directory)
            except:
                print("Could not make directory")
                exit(1)

    data = utils.read_data(log_dir)
    shard = utils.data_processing(data)
    
    utils.set_config({
        'ignore_printing_statistics_summary': False,
        'ignore_drawing_features_vs_time_per_shard' : True,
        'ignore_drawing_features_vs_block_per_shard' : True,
        'ignore_drawing_staking_features_vs_time_per_shard' : True,
        'ignore_drawing_staking_features_vs_block_per_shard' : True,
        'ignore_drawing_features_vs_time' : False,
        'ignore_drawing_features_vs_block' : True
    })
    
    config = utils.config
    ## get the index of the new chain started
    index = []
    for s in shard:
        i = s[s['time_per_block'] < 0].index.tolist()   
        if len(i) == 0:
            break
        i.insert(0,0)
        i.append(len(s))
        index.append(i)
    
    if len(index) == 0:
        new = pd.concat(shard)
        new.reset_index(inplace = True, drop = True)
        utils.visualization(new, fig_dir, html_dir, config)
    else:    
        for i in range(len(index[0])-1):
            df = []
            for s in range(len(shard)):
                df.append(shard[s].iloc[index[s][i]+1:index[s][i+1]])
            new = pd.concat(df)

            fig_path = fig_dir + "chain_" + str(i) + "/"
            if not os.path.exists(fig_path):
                os.makedirs(fig_path)

            utils.visualization(new, fig_path, html_dir, config)
Statistics summary for shard 0
==================================
Total data points: 7745
              size           gas  transaction_per_second  time_per_block
mean   2210.513234  4.361996e+04                0.003420        8.679664
std    5757.154887  3.957627e+05                0.021181        0.488008
min     848.000000  0.000000e+00                0.000000        8.000000
25%    1159.000000  0.000000e+00                0.000000        8.000000
50%    1277.000000  0.000000e+00                0.000000        9.000000
75%    1315.000000  2.338000e+04                0.000000        9.000000
max   37779.000000  5.415196e+06                0.555556       10.000000

Statistics summary for shard 1
==================================
Total data points: 8143
              size           gas  transaction_per_second  time_per_block
mean   1572.498465      7.736706                0.000044        8.245180
std    5565.533428    403.027201                0.002314        0.430042
min     689.000000      0.000000                0.000000        8.000000
25%     689.000000      0.000000                0.000000        8.000000
50%     689.000000      0.000000                0.000000        8.000000
75%     690.000000      0.000000                0.000000        8.000000
max   36649.000000  21000.000000                0.125000        9.000000

Statistics summary for shard 2
==================================
Total data points: 8249
              size  gas  transaction_per_second  time_per_block
mean   1533.646745  0.0                     0.0        8.101467
std    5448.618873  0.0                     0.0        0.300959
min     688.000000  0.0                     0.0        8.000000
25%     688.000000  0.0                     0.0        8.000000
50%     688.000000  0.0                     0.0        8.000000
75%     688.000000  0.0                     0.0        8.000000
max   36648.000000  0.0                     0.0        9.000000

Statistics summary for shard 3
==================================
Total data points: 8273
              size  gas  transaction_per_second  time_per_block
mean   1545.967968  0.0                     0.0        8.098453
std    5481.590849  0.0                     0.0        0.297385
min     689.000000  0.0                     0.0        8.000000
25%     690.000000  0.0                     0.0        8.000000
50%     690.000000  0.0                     0.0        8.000000
75%     690.000000  0.0                     0.0        8.000000
max   36649.000000  0.0                     0.0        9.000000

Features vs Time
PNG saved in ../../graphs/test_logs/ostn/2020_04_16/
==================================
HTML saved in 
HTML saved in 
HTML saved in 
HTML saved in 
HTML saved in 
HTML saved in